def get_chain_questions_answers(scene_struct, template, text_question, structured_question, answer):    
    # text 形式为 obj1 relation1 obj2 relation2 obj3 relation3 obj4
    # obj 存在 前缀 the, relation 存在前缀 that is. 
    # 将 text 中所有 obj 提取出来，形成list，所有relation提取出来形成list 
    text = text_question[len('What is the position of '):][:-1]
    
    # 解析文本，提取对象和关系
    words = text.split()
    objects = []
    relations = []
    i = 0
    while i < len(words):
        break_flag = False
        if words[i] == 'the':
            for j in range(i+1, len(words)):
                if words[j] == 'that':
                    break_flag = True
                    break
            if break_flag:
                j = j
            else:
                j = j + 1
            objects.append(' '.join(words[i:j]))
            assert words[j-1] in ['thing', 'cube', 'sphere', 'cylinder']
            i = j
        elif words[i] == 'that':
            for j in range(i+1, len(words)):
                if words[j] == 'the':
                    break_flag = True
                    break
            if break_flag:
                j = j
            else:
                j = j + 1
            relations.append(' '.join(words[i:j]))
            assert words[j-1] in ['left', 'right', 'front', 'behind']   # "left", "right", "behind", "front"
            assert j - i == 3
            i = j
        else:
            raise ValueError('Unexpected word: {}'.format(words[i]))
    
    mid_questions = []
    # The position of objxx relationxx objxx mentioned above
    for obj_idx in range(len(objects) - 1, -1, -1):
        if obj_idx == len(objects) - 1:
            mid_questions.append('The position of {}:'.format(objects[obj_idx]))
        else:
            mid_questions.append('The position of {} {} {} mentioned above:'.format(objects[obj_idx], relations[obj_idx], objects[obj_idx + 1]))
            
    mid_answer_index = []
    for node in structured_question:
        if node['type'] == 'unique':
            mid_answer_index.append(node['_output'])
    
    mid_answers = []
    for index in mid_answer_index:
        mid_answers.append(scene_struct['objects'][index]['pixel_coords'])
        
    return mid_questions, mid_answers